<?php

    $status = (null) ? 'closed' : 'open';
    $url = 'index.php?dir=' . $dir . '&sub=' . $sub;
    
    if ($contacts) {
	
	echo '<h4 class="' . $status . '" onclick="swap(this);">Contacts (' . sizeof($contacts) . ')</h4>';
	echo '<div>';
        echo '<table><tbody>';
        
        echo '<tr><th>#</th><th>ID</th><th>Name</th><th>Phone</th><th>Email</th><th>Address</th></tr>';
	
        foreach ($contacts as $i=>$contact) {
            $address = $contact->getAddress();
            echo '<tr>';
            echo '<td>' . $i . '</td>';
            echo '<td>' . $contact->getId() . '</td>';
            echo '<td><a href"#">' . $contact->getFullName() . '</a></td>';
            echo '<td>' . $contact->getPhone() . '</td>';
            echo '<td>' . $contact->getEmail() . '</td>';
            echo '<td>' . $address->getAddress() . '</td>';
            
            echo '</tr>';
        }
        echo '</tbody></table>';
        
    } else {
	
	echo '<h4>There are no Contacts!</h4>';
	echo '<div>';

    }
    echo '</div>';
    echo '<button class="create" onclick="window.location="' . $url . '&act=edit">Add Contact</button>';
    
?>